package Year22_Month03.day03;

public class Main1 {
    public boolean checkWon(int[][] board) {
        // write code here
        int key;
        //先搞横
        for(int i = 0;i < board.length;i++){
            if(board[i][0] == board[i][1] && board[i][2] == board[i][1] && board[i][0] != 0){
                key = board[i][0];
                if(key == 1){
                    return true;
                }else{
                    return false;
                }
            }
        }
        //再搞列
        for(int i = 0;i < board.length;i++){
            if(board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[0][i] != 0){
                key = board[0][i];
                if(key == 1){
                    return true;
                }else{
                    return false;
                }
            }
        }
        //接着交叉
        if(board[0][0] == board[1][1] && board[2][2] == board[1][1] && board[0][0] != 0){
            key = board[0][0];
            if(key == 1){
                return true;
            }else{
                return false;
            }
        }
        if(board[0][2] == board[1][1] && board[2][0] == board[1][1] && board[0][2] != 0){
            key = board[0][0];
            if(key == 1){
                return true;
            }else{
                return false;
            }
        }
        return false;
    }
}
